﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using FD.Tool;
namespace FD.Vue.Controllers.Auth
{
    [Route("[controller]/[action]")]
    [ApiController]
    public class UserController : ControllerBase
    {
        [HttpGet]
        public IActionResult info()
        {
           
           
            var actions1 = new { Action = "add", DefaultCheck = false, Describe = "新增" };
            var actions2 = new { Action = "query", DefaultCheck = false, Describe = "查询" };
            var actions3 = new { Action = "get", DefaultCheck = false, Describe = "详情" };
            var actions4 = new { Action = "update", DefaultCheck = false, Describe = "修改" };
            var actions5 = new { Action = "delete", DefaultCheck = false, Describe = "删除" };

            var actionslist = new[]
            {
                actions1,
                actions2,
                actions3,
                actions4,
                actions5
            };

            var actionEntitySetlist = new []
            {
                actions1,
                actions2,
                actions3,
                actions4,
                actions5
            };
          
            var permissions = new 
            {
                RoleId = "admin",
                PermissionId = "dashboard",
                PermissionName = "仪表盘",
                Action= actionslist,
                ActionEntitySet= actionEntitySetlist
            };
            var _roleObj = new
            {
                Id = "admin",
                Name = "管理员",
                Describe = "拥有所有权限",
                Status = "1",
                CreatorId = "system",
                CreateTime = "1497160610259",
                Deleted = "0",
                Permissions = new[] { permissions }
            };

            var user = new
            {
                id = "4291d7da9005377ec9aec4a71ea837f",
                name = "天野远子",
                username = "admin",
                password = "",
                avatar = "/avatar2.jpg",
                status = 1,
                telephone = "",
                lastLoginIp = "27.154.74.117",
                lastLoginTime = 1534837621348,
                creatorId = "admin",
                createTime = 1497160610259,
                merchantCode = "TLif2btpzg079h15bk",
                deleted = 0,
                roleId = "admin",
                role = _roleObj
            };
           
            return Ok(user.ToAntResult());
        }

        [HttpGet]
        public IActionResult nav()
        {
            var data = @" [
    // dashboard
    {
                'name': 'dashboard',
      'parentId': 0,
      'id': 1,
      'meta': {
                    'icon': 'dashboard',
        'title': '仪表盘',
        'show': true
      },
      'component': 'RouteView',
      'redirect': '/dashboard/workplace'
    },
    {
                'name': 'workplace',
      'parentId': 1,
      'id': 7,
      'meta': {
                    'title': '工作台',
        'show': true
      },
      'component': 'Workplace'
    },
    {
                'name': 'monitor',
      'path': 'https://www.baidu.com/',
      'parentId': 1,
      'id': 3,
      'meta': {
                    'title': '监控页（外部）',
        'target': '_blank',
        'show': true
      }
            },
    {
                'name': 'Analysis',
      'parentId': 1,
      'id': 2,
      'meta': {
                    'title': '分析页',
        'show': true
      },
      'component': 'Analysis',
      'path': '/dashboard/analysis'
    },

    // form
    {
                'name': 'form',
      'parentId': 0,
      'id': 10,
      'meta': {
                    'icon': 'form',
        'title': '表单页'
      },
      'redirect': '/form/base-form',
      'component': 'PageView'
    },
    {
                'name': 'basic-form',
      'parentId': 10,
      'id': 6,
      'meta': {
                    'title': '基础表单'
      },
      'component': 'BasicForm'
    },
    {
                'name': 'step-form',
      'parentId': 10,
      'id': 5,
      'meta': {
                    'title': '分步表单'
      },
      'component': 'StepForm'
    },
    {
                'name': 'advanced-form',
      'parentId': 10,
      'id': 4,
      'meta': {
                    'title': '高级表单'
      },
      'component': 'AdvanceForm'
    },

    // list
    {
                'name': 'list',
      'parentId': 0,
      'id': 10010,
      'meta': {
                    'icon': 'table',
        'title': '列表页',
        'show': true
      },
      'redirect': '/list/table-list',
      'component': 'PageView'
    },
    {
                'name': 'table-list',
      'parentId': 10010,
      'id': 10011,
      'path': '/list/table-list/:pageNo([1-9]\\d*)?',
      'meta': {
                    'title': '查询表格',
        'show': true
      },
      'component': 'TableList'
    },
    {
                'name': 'basic-list',
      'parentId': 10010,
      'id': 10012,
      'meta': {
                    'title': '标准列表',
        'show': true
      },
      'component': 'StandardList'
    },
    {
                'name': 'card',
      'parentId': 10010,
      'id': 10013,
      'meta': {
                    'title': '卡片列表',
        'show': true
      },
      'component': 'CardList'
    },
    {
                'name': 'search',
      'parentId': 10010,
      'id': 10014,
      'meta': {
                    'title': '搜索列表',
        'show': true
      },
      'redirect': '/list/search/article',
      'component': 'SearchLayout'
    },
    {
                'name': 'article',
      'parentId': 10014,
      'id': 10015,
      'meta': {
                    'title': '搜索列表（文章）',
        'show': true
      },
      'component': 'SearchArticles'
    },
    {
                'name': 'project',
      'parentId': 10014,
      'id': 10016,
      'meta': {
                    'title': '搜索列表（项目）',
        'show': true
      },
      'component': 'SearchProjects'
    },
    {
                'name': 'application',
      'parentId': 10014,
      'id': 10017,
      'meta': {
                    'title': '搜索列表（应用）',
        'show': true
      },
      'component': 'SearchApplications'
    },

    // profile
    {
                'name': 'profile',
      'parentId': 0,
      'id': 10018,
      'meta': {
                    'title': '详情页',
        'icon': 'profile',
        'show': true
      },
      'redirect': '/profile/basic',
      'component': 'RouteView'
    },
    {
                'name': 'basic',
      'parentId': 10018,
      'id': 10019,
      'meta': {
                    'title': '基础详情页',
        'show': true
      },
      'component': 'ProfileBasic'
    },
    {
                'name': 'advanced',
      'parentId': 10018,
      'id': 10020,
      'meta': {
                    'title': '高级详情页',
        'show': true
      },
      'component': 'ProfileAdvanced'
    },

    // result
    {
                'name': 'result',
      'parentId': 0,
      'id': 10021,
      'meta': {
                    'title': '结果页',
        'icon': 'check-circle-o',
        'show': true
      },
      'redirect': '/result/success',
      'component': 'PageView'
    },
    {
                'name': 'success',
      'parentId': 10021,
      'id': 10022,
      'meta': {
                    'title': '成功',
        'hiddenHeaderContent': true,
        'show': true
      },
      'component': 'ResultSuccess'
    },
    {
                'name': 'fail',
      'parentId': 10021,
      'id': 10023,
      'meta': {
                    'title': '失败',
        'hiddenHeaderContent': true,
        'show': true
      },
      'component': 'ResultFail'
    },

    // Exception
    {
                'name': 'exception',
      'parentId': 0,
      'id': 10024,
      'meta': {
                    'title': '异常页',
        'icon': 'warning',
        'show': true
      },
      'redirect': '/exception/403',
      'component': 'RouteView'
    },
    {
                'name': '403',
      'parentId': 10024,
      'id': 10025,
      'meta': {
                    'title': '403',
        'show': true
      },
      'component': 'Exception403'
    },
    {
                'name': '404',
      'parentId': 10024,
      'id': 10026,
      'meta': {
                    'title': '404',
        'show': true
      },
      'component': 'Exception404'
    },
    {
                'name': '500',
      'parentId': 10024,
      'id': 10027,
      'meta': {
                    'title': '500',
        'show': true
      },
      'component': 'Exception500'
    },

    // account
    {
                'name': 'account',
      'parentId': 0,
      'id': 10028,
      'meta': {
                    'title': '个人页',
        'icon': 'user',
        'show': true
      },
      'redirect': '/account/center',
      'component': 'RouteView'
    },
    {
                'name': 'center',
      'parentId': 10028,
      'id': 10029,
      'meta': {
                    'title': '个人中心',
        'show': true
      },
      'component': 'AccountCenter'
    },
    // 特殊三级菜单
    {
                'name': 'settings',
      'parentId': 10028,
      'id': 10030,
      'meta': {
                    'title': '个人设置',
        'hideHeader': true,
        'hideChildren': true,
        'show': true
      },
      'redirect': '/account/settings/base',
      'component': 'AccountSettings'
    },
    {
                'name': 'BaseSettings',
      'path': '/account/settings/base',
      'parentId': 10030,
      'id': 10031,
      'meta': {
                    'title': '基本设置',
        'show': false
      },
      'component': 'BaseSettings'
    },
    {
                'name': 'SecuritySettings',
      'path': '/account/settings/security',
      'parentId': 10030,
      'id': 10032,
      'meta': {
                    'title': '安全设置',
        'show': false
      },
      'component': 'SecuritySettings'
    },
    {
                'name': 'CustomSettings',
      'path': '/account/settings/custom',
      'parentId': 10030,
      'id': 10033,
      'meta': {
                    'title': '个性化设置',
        'show': false
      },
      'component': 'CustomSettings'
    },
    {
                'name': 'BindingSettings',
      'path': '/account/settings/binding',
      'parentId': 10030,
      'id': 10034,
      'meta': {
                    'title': '账户绑定',
        'show': false
      },
      'component': 'BindingSettings'
    },
    {
                'name': 'NotificationSettings',
      'path': '/account/settings/notification',
      'parentId': 10030,
      'id': 10034,
      'meta': {
                    'title': '新消息通知',
        'show': false
      },
      'component': 'NotificationSettings'
    }
  ]";

            return Ok(data);
        }
    }
}
